﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluorineFx.Security;
using System.Security.Principal;
using System.Collections;
using System.Data;
using WebKpiPage.Data;
namespace RemoteFlunorineFx
{
    public class LoginCommand : GenericLoginCommand
    {
        public override IPrincipal DoAuthentication(string username,Hashtable credentials)
        {
            string password = credentials["password"] as string;

            int dbID = 0;
            List<int> permissions = new List<int>();
            DataSet ds = UserMgr.IsValid_InternalUser_v2(username, password, ref dbID);
            if (dbID == 0)
            {
                GenericIdentity identity = new GenericIdentity(username);
                GenericPrincipal principal = new GenericPrincipal(identity, new string[] { "admin", "privilegeduser" });
                AuthModule.CacheUserInfo(username, ds);
              //  System.Web.HttpContext.Current.Session["userId"] = username;
                return principal;
            }
            else
            {
                return null;
            }
        }
    }
}
